package com.yyx.app1.DiagnosticTools_function.Control.ViewPager.ViewPagerItemControl.secondControl;

import android.content.Context;
import android.graphics.Color;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yyx.app1.Data.DataInit;

import java.util.HashMap;
import java.util.List;

/**
 * Created by yuexing on 2015/9/30.
 */
public class Biochemical0_ListViewAdapter extends BaseAdapter {
    private Context context;
    private List<HashMap<String,String>> map;
    private DataInit dataInit;

    public Biochemical0_ListViewAdapter(Context context) {
        this.context = context;
        dataInit= new DataInit(context,false,"cxlin");
    }

    public void findAll()
    {
        map=dataInit.getRemedyInfo0_SQLiteOperation().getDemo_10name();
        if (map.size()==0)
        {
            Log.i("消息","空");
        }
        this.notifyDataSetChanged();
    }

    public void findAll(String name)
    {
        map = dataInit.getRemedyInfo0_SQLiteOperation().fuzzySearch(name);
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return map.size();
    }

    @Override
    public Object getItem(int position) {
        return map.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView it;
        if (convertView==null)
        {
            it=new TextView(context);
        }
        else
        {
            it=(TextView)convertView;
        }
        String str = map.get(position).get("chineseName")+"("+map.get(position).get("curtailment")+")";
        it.setText(str);
        it.setTextColor(Color.BLACK);
        it.setTextSize(16);
        it.setPadding(40,15,40,15);
        return it;
    }
}
